<?php 
include '../data/data.php';
header("Content-type: text/html; charset=utf-8");
error_reporting(0);
  session_start();
$user=$_SESSION['user']; //获取到的用户名
$pass=$_SESSION['pass']; //获取到的密码
$gameid=$_GET['game_id'];

if($pass==''){
exit ("<script> alert('提示：请重新登录');parent.location.href='/user/login.html'; </script>");
}
if($user==''){
exit ("<script> alert('提示：请重新登录');parent.location.href='/user/login.html'; </script>");
}
$q = "SELECT * FROM user WHERE username='$user'"; 
$result= mysql_query($q, $link);  
$row = mysql_fetch_array($result); 

$huan=$row['huanbang']; //换绑次数
$user=$row['username']; //会员账号
if($huan!='0'){
$ingots = "  UPDATE  user  SET   huanbang=huanbang-1   WHERE username='$user' "; 
mysql_query($ingots, $link);  
$ingotsx = "DELETE FROM games_vip WHERE game_id='$gameid' AND user_id='$user'"; 
mysql_query($ingotsx, $link);  
exit ("<script> alert('提示：清理成功，请前往游戏授权界面重新授权');parent.location.href='/user/games.html'; </script>");
}else{
exit ("<script> alert('提示：重绑次数不足');parent.location.href='/user/games.html'; </script>");
}

?>